package com.zl.controller;

import com.zl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller
public class UserController2 {
    //1.属性注入
    //@Autowired
//    @Resource
//    private UserService userService;

    //2.setter注入
    private UserService userService;
    @Resource
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    //3.构造方法注入(Resource不支持构造方法注入的,会报错)
//    private UserService userService;
//    @Resource
//    public UserController2(UserService userService) {
//        this.userService=userService;
//
//    }

    public void doController2(){
        userService.doService();
        System.out.println("doController2");
    }
}
